package com.yes_iot.service.impl;

import com.yes_iot.dao.VisualMoudleDao;
import com.yes_iot.entity.VisualMoudle;
import com.yes_iot.service.VisualDisplayService;
import com.yes_iot.service.VisualMoudleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Service
public class VisualMoudleServiceImpl extends AbstractEntityService implements VisualMoudleService {
    @Autowired
    private VisualMoudleDao visualMoudleDao;
    @Override
    public List<VisualMoudle> findVisualMoudelByParentId(String parentId) {
        return visualMoudleDao.findVisualMoudelByParentId(UUID.fromString(parentId));
    }

    @Override
    public VisualMoudle save(VisualMoudle visualMoudle) {
        return visualMoudleDao.save(visualMoudle);
    }

    @Override
    public void deleteById(String id) {
        visualMoudleDao.deleteById(UUID.fromString(id));
    }

    @Override
    public VisualMoudle findById(String id) {
        Optional<VisualMoudle> byId = visualMoudleDao.findById(UUID.fromString(id));
        return byId.orElse(null);

    }

    @Override
    public List<VisualMoudle> findByVisualMoudleLibraryId(UUID id) {
        return visualMoudleDao.findByVisualMoudleLibraryId(id);
    }
}
